package com.stu.stusystem.common;

import io.swagger.annotations.ApiModelProperty;

/**
 * @author: cxt
 * @time: 2021/3/18
 */
public class OffsetPage {
    public final static int DEFAULT_LIMIT = 12;
    public final static int MAX_LIMIT = 50;

    @ApiModelProperty("当前页码")
    private Integer page;

    @ApiModelProperty("当前页数量")
    private Integer limit;

    public Integer getPage() {
        if (this.page == null){
            this.page = 1;
        }
        return page;
    }

    public void setPage(Integer page) {
        this.page = page;
    }

    public Integer getLimit() {
        if (this.limit == null){
            this.limit = 12;
        }
        return limit;
    }

    public void setLimit(Integer limit) {
        if (limit > MAX_LIMIT) {
            limit = MAX_LIMIT;
        } else if (limit <= 0) {
            limit = DEFAULT_LIMIT;
        }
        this.limit = limit;
    }
}
